package two_xia.ex9.Demo11;

class HRVisitor implements Visitor {
    private double totalSalary = 0;
    private double totalOvertime = 0;
    private double totalLeave = 0;

    public void visit(RegularEmployee regularEmployee) {
        // 正式员工工资和时间计算
        double overtimePay = regularEmployee.getWorkHours() > 40 ? (regularEmployee.getWorkHours() - 40) * 100 : 0;
        double leaveDeduction = regularEmployee.getWorkHours() < 40 ? (40 - regularEmployee.getWorkHours()) * 80 : 0;
        double salary = regularEmployee.getBaseSalary() + overtimePay - leaveDeduction;

        totalSalary += salary;
        totalOvertime += overtimePay;
        totalLeave += leaveDeduction;
    }

    public void visit(TempEmployee tempEmployee) {
        // 临时工工资和时间计算
        double salary = tempEmployee.getWorkHours() * tempEmployee.getBaseSalary();

        totalSalary += salary;
    }

    public void printSummary() {
        System.out.println("总工资：" + totalSalary);
        System.out.println("总加班费：" + totalOvertime);
        System.out.println("总请假扣款：" + totalLeave);
    }
}
